<?php
class p_chapter_tvbcom_category extends Model{
	public static function getTableName(){
		return 'p_chapter-tvbcom_category';
	}

    public function getPrimaryKey()
    {
        return array('chapter_id', 'category_id');
    }

	public function delBySql($id)
	{
		$sql = "delete from `".self::getTableName()."` where chapter_id='{$id}'";
		return Model::$dbo["w"]->getDbHandle()->exec($sql);
	}

	public function getCategoryByChapterID($id)
	{
        $sql = "SELECT * FROM `".self::getTableName()."` a, tvbcom_category b 
            WHERE a.chapter_id='{$id}' AND a.category_id=b.id
            ORDER BY a.rank";
		return Model::$dbo["r"]->findBySql(__class__, $sql);
	}
}
?>
